﻿@{
    ViewBag.Title = "酒店设置-集团管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Header
{
    <script type="text/javascript">
        $(document).ready(function () {
            $('#datagrid').datagrid({
                url: "/Group/GetGroupList",
                rownumbers: true,
                fit: true,
                singleSelect: true,
                toolbar: '#toolbar',
                columns: [[{ field: 'GroupID', hidden: true, title: '@Html.OutputText("GroupID".Toi18n())', width: 100 },
                    { field: 'Province', title: '@Html.OutputText("province".Toi18n())', width: 100 },
                     { field: 'City', title: '@Html.OutputText("city".Toi18n())', width: 100 },
                     { field: 'County', title: '@Html.OutputText("county".Toi18n())', width: 100 },
                    { field: 'GroupName', title: '@Html.OutputText("GroupName".Toi18n())', width: 120 },
                    { field: 'GroupAccount', title: '@Html.OutputText("GroupAccount".Toi18n())', width: 120 },
                    { field: 'GroupAccStatus', title: '@Html.OutputText("GroupAccStatus".Toi18n())', width: 120, formatter: function (value, row, index) {
                        return value == 'on' ? locale.status.status_on : locale.status.status_off;
                    }
                    },
                    { field: 'GroupHotelNum', title: '@Html.OutputText("GroupHotelNum".Toi18n())', width: 120 },
                    { field: 'other', title: '', width: 120, formatter: function (value, row, index) {
                        return '<a onclick="doDetail(\'' + row.GroupName + '\',\'' + row.GroupID + '\')" href="javascript:void(0)">' + locale.btn.btn_detail + '</a>';
                    }
                    }]]
            });

            $('#win').window('close');

            function doSearch(val) {
                if (val != '') {
                    //do search
                }
            }

            window.validSearchParam = function () {
                var val = $('#GroupName').val();
                val == '' ? $('#GroupName').focus() : doSearch(val);
            };
            window.doReload = function () {
                $('#datagrid').datagrid('reload');
            };
            window.doAdd = function () {
                $('#win').window({
                    title: locale.btn.btn_add
                });
                $('#win').window('open');
            };
            window.doEdit = function () {
                var data = $('#datagrid').datagrid('getSelected');
                if (data) {
                    $('#ff').form('load', {
                        GroupID: data.GroupID,
                        GroupName: data.GroupName,
                        GroupAccount: data.GroupAccount,
                        GroupAccStatus: data.GroupAccStatus,
                        Province: data.Province,
                        GroupHotelNum: data.GroupHotelNum
                    });
                    $('#win').window({
                        title: locale.btn.btn_edit
                    });
                    $('#win').window('open');
                } else {
                    $.messager.alert(locale.msg.msg_title_info, locale.msg.msg_question_edit_null, 'info');
                }
            };
            window.doRemove = function () {
                var data = $('#datagrid').datagrid('getSelected');
                if (data) {
                    $.messager.confirm(locale.msg.msg_title_ques, locale.fn.fn_remove(data.GroupName), function (r) {
                        if (r) {
                            var rowIndex = $('#datagrid').datagrid('getRowIndex', data);
                            $('#datagrid').datagrid('deleteRow', rowIndex);
                        }
                    });
                } else {
                    $.messager.alert(locale.msg_title_info, msg_question_remvove_null, 'info');
                }
            };
        });

        function doDetail(t, id) {
            if (t && id && t != id) {
                var href = "/Group/GroupDetail/" + g_guid + "?GroupID=" + id;
                window.top.addTab(locale.fn.fn_detail(t), href, 'icon-edit');
            }
        }
    </script>
}
<table id="datagrid">
    <!--datagrid-->
</table>
<div id="toolbar" style="padding: 5px; height: auto">
    <div style="margin-bottom: 5px">
        <a href="#" onclick="doAdd()" class="easyui-linkbutton" iconcls="icon-add" plain="true">
            @Html.OutputText("add".Toi18n())</a> <a href="#" class="easyui-linkbutton" onclick="doEdit()"
                iconcls="icon-edit" plain="true">@Html.OutputText("edit".Toi18n())</a> <a href="#"
                    class="easyui-linkbutton" iconcls="icon-remove" onclick="doRemove()" plain="true">@Html.OutputText("remove".Toi18n())</a>
        <a href="#" class="easyui-linkbutton" iconcls="icon-reload" plain="true" onclick="doReload()">@Html.OutputText("reload".Toi18n())</a>
    </div>
    <div>
        <label for="GroupName">
            @Html.OutputText("GroupName".Toi18n())：</label>
        <input id="GroupName" class="easyui-validatebox" data-options="required:true,validType:''" />
        <a id="btn" href="#" onclick="validSearchParam()" class="easyui-linkbutton" data-options="iconCls:'icon-search'">
            @Html.OutputText("search".Toi18n())</a>
    </div>
</div>
